﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ChoiceFuc : MonoBehaviour {
	public ReadText rt;
	public ReadText.Choice_NextText ct;
	private bool pressed = false;
	Button bt;
	// Use this for initialization
	public void ClickFun()
	{
		pressed = true;
		fuc();
	}
	void Start()
	{
		bt = GetComponent<Button> ();
		bt.Select();
	}
	void fuc()
	{
		if (pressed)
		{    
			rt.TextToLines(ct.nextText);
			//ReadTextExample theComuObj = GameObject.FindObjectOfType<ReadTextExample>();
			ReadTextExample theComuObj = GetComponentInParent<ReadTextExample>();
			string myname = GetComponentInChildren<Text>().text;
			theComuObj.theChoices.Add(myname);
			theComuObj.isCreated = false;
			foreach(GameObject abtn in theComuObj.btns){
				Destroy(abtn);
			}
		}
	}
}
